﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DataAccessLayer.Entity;
namespace DataAccessLayer.Adapter
{
    public class PhongThiAdapter
    {
        clsKetNoiCSDL kn = new clsKetNoiCSDL();
        public DataTable LoadPhongThi()
        {
            return kn.LoadDL("tbPhongThi_SelectAll");
        }
        public void ThemPhong(clsPhongThi clsPhong)
        {
            int Npa = 2;
            string sql = "tbPhongThi_Insert";
            string []name=new string[Npa];
            object []value=new object[Npa];
            name[0] = "@MaPhong"; value[0] = clsPhong.MaPhong;
            name[1] = "@TenPhong"; value[1] = clsPhong.TenPhong;
            kn.UpdateDL(sql,name,value,Npa);
        }

        public void SuaPhong(clsPhongThi clsPhong)
        {
            int Npa = 2;
            string sql = "tbPhongThi_Update";
            string[] name = new string[Npa];
            object[] value = new object[Npa];
            name[0] = "@MaPhong"; value[0] = clsPhong.MaPhong;
            name[1] = "@TenPhong"; value[1] = clsPhong.TenPhong;
            kn.UpdateDL(sql, name, value, Npa);
        }
        public void XoaPhong(clsPhongThi clsPhong)
        {
            int Npa = 1;
            string sql = "tbPhongThi_Delete";
            string[] name = new string[Npa];
            object[] value = new object[Npa];
            name[0] = "@MaPhong"; value[0] = clsPhong.MaPhong;
            //name[1] = "@TenPhong"; value[1] = clsPhong.TenPhong;
            kn.UpdateDL(sql, name, value, Npa);
        }
        public object KiemTraMa(clsPhongThi clsPhong)
        {
            string sql = "tbPhongThi_KiemTraMa";
            int N = 1;
            string[]name=new string[N];
            object []value=new object[N];
            name[0] = "@MaPhong"; value[0] = clsPhong.MaPhong;
            return kn.KTTrungMa(sql,name,value,N);
        }
    }
}
